package com.wiwf.model.magicapi;

import javax.annotation.Resource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.ssssssss.magicapi.datasource.model.MagicDynamicDataSource;

import com.alibaba.druid.pool.DruidDataSource;
import com.wiwf.model.mapper.config.DataSourceAdminBean;
import com.wiwf.model.mapper.config.DataSourceBusinessBean;

/**
 * Magic Api 数据源配置
 * @author kehui
 */
@Configuration
public class MagicDataCfg {

    @Resource(name = DataSourceAdminBean.NAME)
    private DruidDataSource adminDbSource;

    @Resource(name = DataSourceBusinessBean.NAME)
    private DruidDataSource businessDbSource;

    @Bean
    MagicDynamicDataSource magicDynamicDataSource(){
        MagicDynamicDataSource dynamicDataSource = new MagicDynamicDataSource();
        dynamicDataSource.setDefault(businessDbSource, 1000);
        dynamicDataSource.add("admin", adminDbSource, 1000);
        return dynamicDataSource;
    }

}